'use strict';

const Service = require('egg').Service;

class ScoresService extends Service {
  async add(obj) {
    let {name,theory,skill,stu} = obj;
    let sql = `insert into scores (name,theory,skill,stu) values ('${name}','${theory}','${skill}','${stu}')`;
    let res = await this.app.mysql.query(sql);
    return res;
  }
  async list(){
      let sql =  `select * from scores`;
      let res = await this.app.mysql.query(sql);
      return res;
  }
  async update(obj) {
    let { id, name, theory, skill, stu } = obj;
    let sql = `update scores set name='${name}',theory='${theory}',skill='${skill}',stu='${stu}' where id=${id}`;
    let res = await this.app.mysql.query(sql);
    return res;
  }
  async del(id) {
    let sql = `delete from scores where id in (${id})`;
    let res = await this.app.mysql.query(sql);
    return res;
}
}
module.exports = ScoresService;
